home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 November / EnigmA AMIGA RUN 02 (1995)(G.R. Edizioni)(IT)[!][issue 1995-11][Skylink CD].iso / earcd / program / gcc / libmat.lha / src / mplus.cc < prev    next >
C/C++ Source or Header  |  1980-01-01  |  447b  |  26 lines

  1. //                MATRIX LIB
  2. //            TOMMY JOHANSSON 1995
  3.  
  4. #include "matrix.h"
  5.  
  6. Matrix operator + (const Matrix& A,const Matrix& B)
  7. {
  8.     int i,j;
  9.     #ifdef DEBUG
  10.         puts("Adderar matris.");
  11.     #endif
  12.  
  13.     #ifdef CHECK
  14.         if((A.m!=B.m)&&(A.n!=B.n))    
  15.         {
  16.             printf("Felaktiga dimensioner %d<>%d eller %d<>%d!\n",A.m,B.m,A.n,B.n);    
  17.             exit(0);
  18.         }
  19.     #endif
  20.     Matrix C(A.m,A.n);
  21.     for(i=1;i<=A.m;i++)
  22.         for(j=1;j<=A.n;j++)
  23.             C.koff[i][j]=A.koff[i][j]+B.koff[i][j];
  24.     return(C);
  25. }
  26.